package demo1;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Iterator;

/**
 * 实现对输入的数据快速排序，可以达到边输入 便排序并打印*/
public class Sort {
    public void sort() {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Integer> arrayList = new ArrayList<>();
        while(scanner.hasNextInt()) {
            int num = scanner.nextInt();
            arrayList.add(num);
            arrayList.sort((o1,o2)->{return o1-o2;});
            Iterator it = arrayList.iterator();
            System.out.print("排序后：");
            while(it.hasNext()) {
                System.out.print(it.next()+" ");
            }
        }
    }
}
